namespace Angelus.Data.Linq.OracleClient
{
    using System.Collections.Generic;
    using System.Data.OracleClient;
    using System.Data.DLinq;
    using System.Data.DLinq.Provider;

    /// <summary>
    /// 
    /// </summary>
    internal class OracleStoredProcedureResult : StoredProcedureResult
    {
        #region Fields

        private readonly OracleStoredProcedureResultImpl _result;

        #endregion

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="command"></param>
        /// <param name="function"></param>
        internal OracleStoredProcedureResult(OracleContext context, OracleCommand command, MetaFunction function)
        {
            this._result = new OracleStoredProcedureResultImpl(context, command, function, true);
        }

        #endregion

        #region Properties

        /// <summary>
        /// 
        /// </summary>
        public override int? ReturnValue
        {
            get { return this._result.ReturnValue; }
        }

        #endregion

        #region Stored Procedure Execution

        /// <summary>
        /// 
        /// </summary>
        public void ExecuteStoredProcedure()
        {
            this._result.ExecuteStoredProcedure();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterIndex"></param>
        /// <returns></returns>
        public override object GetParameterValue(int parameterIndex)
        {
            return this._result.GetParameterValue(parameterIndex);
        }

        #endregion
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    internal class OracleStoredProcedureResult<T> : StoredProcedureResult<T>
    {
        #region Fields

        private readonly OracleStoredProcedureResultImpl _result;

        #endregion

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="command"></param>
        /// <param name="function"></param>
        internal OracleStoredProcedureResult(OracleContext context, OracleCommand command, MetaFunction function)
        {
            this._result = new OracleStoredProcedureResultImpl(context, command, function, false);
        }

        #endregion

        #region Disposable Implementation

        /// <summary>
        /// 
        /// </summary>
        public void Dispose()
        {
            this._result.Dispose();
        }

        #endregion

        #region Properties

        /// <summary>
        /// 
        /// </summary>
        public override int? ReturnValue
        {
            get { return this._result.ReturnValue; }
        }

        #endregion

        #region Stored Procedure Execution

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override IEnumerator<T> GetEnumerator()
        {
            return this._result.GetResults<T>(false).GetEnumerator();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterIndex"></param>
        /// <returns></returns>
        public override object GetParameterValue(int parameterIndex)
        {
            return this._result.GetParameterValue(parameterIndex);
        }

        #endregion
    }
}